﻿import numpy as np
import random as rd
import adaBoost as ab

print("hello world")
data=np.ones((3,4));
print(data);
s=np.shape(data)
print(s)
def loadDataSet():
    path="C:/Develop/data/mlia/Ch06/testSet.txt"
    file=open(path);
    dataSet=[]
    labelSet=[]
    for line in file.readlines():
        print("line")
        print(line)
        strs=line.strip().split('\t')
        for str in strs:
            print(str)
        dataSet.append([float(strs[0]), float(strs[1])])
        labelSet.append(float(strs[2]))

    print(dataSet)
    print(labelSet)

    dataMat=np.mat(dataSet)
    labelMat=np.mat(labelSet)
    print(dataMat)
    print(labelMat)
    return dataMat,labelMat

def selectJrand(i,m):
    j=i
    while(j==i):
        j=int(rd.uniform(0,m))

    return j

def clipAlpha(a,h,l):
    if a>h:
        a=h
    if a<l:
        a=l
    return a

dataMat, labels=ab.loadSimpleData()


len=len(labels)
D=np.mat(np.ones((len,1))/len)
ab.buildClassify(dataMat,labels,D)

ab.plotSimpleData(dataMat, labels)